// use super::socketd_utils::tri_consumer::TriConsumer;
use socketd_utils::tri_consumer::TriConsumer;
/**
 * 流接口
 *
 * @author noear
 * @since 2.1
 */
pub trait Stream {
    /// 流Id
    fn sid(&self) -> String;

    /// 是否完成
    fn is_done(&self) -> bool;

    /// 异常发生时
    fn then_error<F>(&mut self, on_error: F) -> &mut Self
    where
        F: FnMut(Box<dyn std::error::Error>) + 'static;

    /// 进度发生时
    ///
    /// # 参数
    /// * `on_progress` - (is_send, val, max)
    fn then_progress<F>(&mut self, on_progress: F) -> &mut Self
    where
        F: TriConsumer<bool, i32, i32> + 'static;
}
